package com.basics.api.enums.socket;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum MessageEnum {
    PUSH_CHANNEL_ALL("PUSH_CHANNEL_ALL", "推首页整体频道列表,包含首页角标"),
    PUSH_CHANNEL_INFO("PUSH_CHANNEL_INFO", "推单个频道数据"),
    DELETE_CHANNEL("DELETE_CHANNEL", "删除频道");

    /** 状态码 **/
    private String code;
    /** 状态描述 **/
    private String description;

    /**
     * 根据code查找
     *
     * @param code code
     * @return 枚举
     */
    public static MessageEnum find(String code) {
        return Arrays.stream(MessageEnum.values())
                .filter(input -> input.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
